package com.tony.util.utils;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.crypto.digest.DigestUtil;

import java.nio.charset.StandardCharsets;

/**
 * @author 96543
 */
public class PasswordUtil {

    public static String encode(String password,String salt){
        return DigestUtil.md5Hex((password + salt).getBytes(StandardCharsets.UTF_8));
    }

    /**
     * 获取4个随机字母
     *
     * @return 随机字母
     */
    public static String getSalt() {
        return RandomUtil.randomString(RandomUtil.BASE_CHAR, 4);
    }
}
